import 'package:mziot/app/data/scene_params_entity.dart';
import 'package:mziot/generated/json/base/json_convert_content.dart';

SceneParamsEntity $SceneParamsEntityFromJson(Map<String, dynamic> json) {
  final SceneParamsEntity sceneParamsEntity = SceneParamsEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    sceneParamsEntity.id = id;
  }
  final String? sceneName = jsonConvert.convert<String>(json['sceneName']);
  if (sceneName != null) {
    sceneParamsEntity.sceneName = sceneName;
  }
  final String? startTime = jsonConvert.convert<String>(json['startTime']);
  if (startTime != null) {
    sceneParamsEntity.startTime = startTime;
  }
  final String? endTime = jsonConvert.convert<String>(json['endTime']);
  if (endTime != null) {
    sceneParamsEntity.endTime = endTime;
  }
  final int? lightRate = jsonConvert.convert<int>(json['lightRate']);
  if (lightRate != null) {
    sceneParamsEntity.lightRate = lightRate;
  }
  final bool? isLock = jsonConvert.convert<bool>(json['isLock']);
  if (isLock != null) {
    sceneParamsEntity.isLock = isLock;
  }
  final List<SceneParamsLightOffs>? lightOffs =
      jsonConvert.convertListNotNull<SceneParamsLightOffs>(json['lightOffs']);
  if (lightOffs != null) {
    sceneParamsEntity.lightOffs = lightOffs;
  }
  final String? remark = jsonConvert.convert<String>(json['remark']);
  if (remark != null) {
    sceneParamsEntity.remark = remark;
  }
  final List<int>? groupIds = jsonConvert.convertListNotNull<int>(json['groupIds']);
  if (groupIds != null) {
    sceneParamsEntity.groupIds = groupIds;
  }
  return sceneParamsEntity;
}

Map<String, dynamic> $SceneParamsEntityToJson(SceneParamsEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['sceneName'] = entity.sceneName;
  data['startTime'] = entity.startTime;
  data['endTime'] = entity.endTime;
  data['lightRate'] = entity.lightRate;
  data['isLock'] = entity.isLock;
  data['lightOffs'] = entity.lightOffs?.map((v) => v.toJson()).toList();
  data['remark'] = entity.remark;
  data['groupIds'] = entity.groupIds;
  return data;
}

SceneParamsLightOffs $SceneParamsLightOffsFromJson(Map<String, dynamic> json) {
  final SceneParamsLightOffs sceneParamsLightOffs = SceneParamsLightOffs();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    sceneParamsLightOffs.id = id;
  }
  final String? start = jsonConvert.convert<String>(json['start']);
  if (start != null) {
    sceneParamsLightOffs.start = start;
  }
  final String? end = jsonConvert.convert<String>(json['end']);
  if (end != null) {
    sceneParamsLightOffs.end = end;
  }
  final int? rate = jsonConvert.convert<int>(json['rate']);
  if (rate != null) {
    sceneParamsLightOffs.rate = rate;
  }
  return sceneParamsLightOffs;
}

Map<String, dynamic> $SceneParamsLightOffsToJson(SceneParamsLightOffs entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['start'] = entity.start;
  data['end'] = entity.end;
  data['rate'] = entity.rate;
  return data;
}
